package com.zlzxm.shoesmarket.view.adapter;

import android.widget.ImageView;

import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.google.android.flexbox.FlexboxLayoutManager;
import com.zlzxm.shoesmarket.R;
import com.zlzxm.shoesmarket.util.ZViewHelp;
import com.zlzxm.shoesmarket.view.adapter.entity.EntityTransferGood;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
 * CREATE BY zlzxm ON 4/13/21
 * <br> todo 嵌套recycleview 需要优化
 */
public class ADTransferGoods extends BaseQuickAdapter<EntityTransferGood, BaseViewHolder> {

    public ADTransferGoods(@Nullable List<EntityTransferGood> data) {
        super(R.layout.item_transfer_goods, data);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, EntityTransferGood entity) {

        RecyclerView recyclerView = holder.getView(R.id.rvSize);
        ImageView imageView = holder.getView(R.id.ivFace);


        holder.setText(R.id.tvTitle,entity.getName());
        holder.setText(R.id.tvNum,entity.getNum());
        holder.setText(R.id.tvPeopleNum,entity.getPeopleNum());

        RequestOptions requestOptions = new RequestOptions().transform(new
                CenterCrop(),new RoundedCorners(ZViewHelp.dpTopx(getContext(),10)));


        Glide.with(getContext())
                .load(entity.getFaceUrl())
                .apply(requestOptions)
                .into(imageView);

        ADGoodsTag adGoodsTag = new ADGoodsTag(entity.getTag());
        recyclerView.setLayoutManager(new FlexboxLayoutManager(getContext()));
        recyclerView.setAdapter(adGoodsTag);


    }
}
